You are here: Statements and Functions > Read
Syntax samples
READ <file ID>, <name>
READ File1, Var1
Reads the next numeric value from a general read file and assigns that value to a name. General read files are defined in the External Files Editor. When reading from a file, ProModel skips all non-numeric data, such as text, and reads the next numeric value. Thus comments and notes may be included in a read file. Multiple replications of a model will continue reading from a file where the previous replication left off unless reset with the RESET statement.
Please note
ProModel reads a period (.) in a General read file as a zero. To avoid this, you should use the comment symbol (#) in front of notes and comments that contain a period.
READ can read ASCII files. Most spreadsheet programs can convert spreadsheets to ASCII files (.TXT) and comma-delimited files (.CSV).
If a read statement is not assigning the right values to the proper name, there may be numeric information in the read-file’s header information (notes and comments). Additionally, if the values are being read into an array, the array indices may not be incremented properly between reads.
If a read file should be read more than once in a model, it may need to be reset. One way to tell when a file needs to be reset is with an end of file marker such as 9999 and the following two lines of logic.
Read File1,Value
IF Value= 9999 then RESET File1
Any logic.
Components
<file ID>
The file identifier as defined in the External Files Editor.
<name>
The variable, array element, or attribute to be assigned the value.
Example
The example below shows an outside file being read in the Arrival logic for entity type Box. In this case three values representing the length, width and depth of each Box are listed on each line of a file called "Size.Dat." The File ID for this file is simply Size. Length, Width, and Depth are all entity attributes.
External Files. Also see RESET and CLOSE.